home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 557 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.0 KB  |  32 lines

  1. Path: mips.complang.tuwien.ac.at!schwarz
  2. From: schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz)
  3. Newsgroups: comp.std.c
  4. Subject: Re: integral types in switch expressions
  5. Date: 13 Mar 1996 20:52:13 GMT
  6. Organization: TU Wien
  7. Message-ID: <4i7cht$osd@news.tuwien.ac.at>
  8. References: <DnKnzv.8t6%spenford@zoo.toronto.edu> <Dnt4vo.Gu0@tigadmin.ml.com> <4i3s1r$s4o@news.tuwien.ac.at>
  9. NNTP-Posting-Host: mips.complang.tuwien.ac.at
  10.  
  11. I recently wished for an extension of the switch statement, allowing not
  12. only constant integral expressions but also constant pointer expressions in
  13. case labels.  In private email, Chris Torek (torek@elf.bsdi.com)
  14. has pointed out that it is undecideable at compile-time if two constant
  15. pointer expressions are in fact equal.  Given
  16.  
  17. extern int a [N], b;
  18.  
  19. ``a + N == &b'' is allowable; it is easy to construct
  20. situations where this is detectable only at link time.  In this case,
  21. the following fragment is no longer well-defined:
  22.  
  23. int *p;
  24. switch (p) {
  25. case a + N: ...
  26. case &b:    ...
  27. }
  28.  
  29. and that is the death knell of my proposal.
  30.  
  31. Konrad Schwarz
  32.